package com.itheima.feign;

import com.itheima.feign.impl.ItemFeignFallback;
import com.itheima.feign.impl.ItemFeignFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * @Author：shenkunlin
 * @date： 2021/7/12 11:57
 * @Description：
 ***/
//@FeignClient(name = "被调用的服务名字： 调用当前接口中指定的方法时候，要调用远程服务的指定方法")
//@FeignClient(name = "item",path = "/item",fallback = ItemFeignFallback.class)
@FeignClient(name = "item",path = "/item",fallbackFactory = ItemFeignFallbackFactory.class)
//@RequestMapping(value = "/item")   如果使用Hystrix熔断，此时会报错
public interface ItemFeign {

    /***
     * 调用item中哪个Controller的方法
     */
    @GetMapping(value = "/{id}/{count}")
    int decrCount(@PathVariable(value = "id")Integer id,
            @PathVariable(value = "count")Integer count);

    /***
     * 两种方法：
     *  1：给OpenFeign接口编写一个实现类，并且在@FeignClient中指定fallback=""
     *
     *  2：创建一个普通类，继承FallbackFactory<泛型>,且在@FeignClient中指定fallbackFactory=""
     *      泛型->执行远程调用的接口->ItemFeign
     */
}
